package org.inspursc.s0517.health.common.service.impl;

import lombok.extern.slf4j.Slf4j;
import org.inspursc.s0517.health.common.dao.SysRoleUserDao;
import org.inspursc.s0517.health.common.entity.SysRoleUser;
import org.inspursc.s0517.health.common.service.SysRoleUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
@Slf4j
public class SysRoleUserServiceImpl implements SysRoleUserService {

    @Autowired
    private SysRoleUserDao roleUserDao;

    @Override
    public SysRoleUser save(SysRoleUser roleUser) {
        return roleUserDao.save(roleUser);
    }

    @Override
    public SysRoleUser findById(Integer id) {
        return roleUserDao.getOne(id);
    }

    @Override
    public boolean deleteById(Integer id) {

        try {
            roleUserDao.deleteById(id);
            return true;
        } catch (Exception e) {
            log.error("【删除失败】", e.getMessage());
            return false;
        }
    }

    @Override
    public List<SysRoleUser> findBySysUserId(Integer userId) {
        return roleUserDao.findBySysUserId(userId);
    }
}
